package week5;

import java.util.Scanner;

public class Q3 {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        System.out.print("请输入一个整数：");
        int num=scanner.nextInt();
        boolean isPalindrome =isPalindrome(num);
        if (isPalindrome){
            System.out.println(num+"是回文数");
        }else {
            System.out.println(num+"不是回文数");
        }
        scanner.close();
    }
    public  static boolean isPalindrome(int num){
        if (num<0){
            return false;
        }
        int originalNum=num;
        int reversedNum=0;
        while(num!=0){
            int digit =num %10;
            reversedNum=reversedNum*10+digit;
            num=num/10;
        }
        return originalNum==reversedNum;
    }
}
